﻿@inject IStringLocalizer<Foo> LocalizerFoo

<ValidateForm Model="@Model">
    <Row ItemsPerRow="ItemsPerRow.Three">
        <CheckboxList @bind-Value="@Model.Hobby" Items="Hobbys" />
        <BootstrapInput @bind-Value="@Model.Address" />
        <DateTimePicker @bind-Value="@Model.DateTime" />
        <BootstrapInputNumber @bind-Value="@Model.Count" />
        <Switch @bind-Value="@Model.Complete" />
        <Select @bind-Value="@Model.Education" />
    </Row>
</ValidateForm>

@code {
    private RowFoo Model { get; } = new()
    {
        Name = "张三",
        Count = 23,
        Address = "测试地址",
        DateTime = new DateTime(1997, 12, 05),
        Educations = new List<EnumEducation> { EnumEducation.Primary, EnumEducation.Middle }
    };

    [NotNull]
    private IEnumerable<SelectedItem>? Hobbys { get; set; }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        Hobbys = Foo.GenerateHobbys(LocalizerFoo);
    }

    private class RowFoo : Foo
    {
        [Required(ErrorMessage = "请选择学历")]
        [Display(Name = "学历")]
        [AutoGenerateColumn(Order = 60)]
        public List<EnumEducation>? Educations { get; set; }
    }
}
